#ifndef __SIPINVITEDIALOG_HPP__
#define __SIPINVITEDIALOG_HPP__

#include "SipResipConfigure.hpp"
#include "SipClnInviteTrans.hpp"
#include "SipSrvInviteTrans.hpp"
#include "SipDialog.hpp"

#include "resip/stack/SipMessage.hxx"

namespace wtsip{

class CSipClnTransaction;
class CSipSrvTransaction;
class CSipInviteDlgHandle;
//class CSipClnInviteTransCallback;
//class CSipSrvInviteTransListener;


class RESIP_PUBLIC CSipInviteDialog: 
    public CSipDialogBase,
    public CSipClnInviteTransCallback,
    public CSipSrvInviteTransListener
{

public:

    CSipInviteDialog(CSipDialogSet& dlgset, const resip::Uri& local, const resip::Uri& remote);

    CSipInviteDialog(CSipDialogSet& dlgset, SipMessage& msg);

    ~CSipInviteDialog();

    bool registerInvHandle(CSipInviteDlgHandle* handle);

    bool unregisterInvHandle();

    SipMessage* createInvite();

    SipMessage* createCancel();

    SipMessage* createCancelOK();

    SipMessage* createAck();

    SipMessage* createFailAck();

    SipMessage* createInvResponse(int code);

    SipMessage* createBye();

    virtual bool send(std::auto_ptr<SipMessage> msg);

    virtual bool dispatch(SipMessage* msg);

    virtual bool removeTransaction(CSipSrvTransaction* stran);

    virtual bool removeTransaction(CSipClnTransaction* ctran);

    virtual bool terminate();

    virtual bool hasHandle();

    /////////////  CSipClnInviteTransCallback  

    virtual bool onTrying(CSipClnTransaction& clntran, SipMessage& msg);

    virtual bool onCanceled(CSipClnTransaction& clntran, SipMessage& msg);

    virtual bool onFailed(CSipClnTransaction& clntran, SipMessage& msg);

    virtual bool onSuccessed(CSipClnTransaction& clntran, SipMessage& msg);

    //virtual bool onRequest(CSipClnTransaction& clntran, SipMessage& msg);

    virtual bool onResponse(CSipClnTransaction& clntran, SipMessage& msg);

    virtual bool onStateChange(CSipClnTransaction& clntran, int newState);

    ///////////// CSipSrvInviteTransCallback

    virtual bool onCancel(CSipSrvTransaction& srvtran, SipMessage& msg);

    virtual bool onFailed(CSipSrvTransaction& srvtran, SipMessage& msg);

    virtual bool onRequest(CSipSrvTransaction& srvtran, SipMessage& msg);

    //virtual bool onResponse(CSipSrvTransaction& srvtran, SipMessage& msg);

    virtual bool onStateChange(CSipSrvTransaction& srvtran, int newState);

private:

    CSipInviteDlgHandle* m_invHandle;

    CSipClnInviteTrans* m_inviteClntran;

    CSipSrvInviteTrans* m_inviteSrvtran;

};


}

#endif

